clear

do "gr2009.do"

*Construct graduation rate for 150% normal time
gen bacohortx = grtotlt if grtype==8
bysort unitid: egen bacohort = max(bacohortx)

gen bacompl150x = grtotlt if grtype==12
bysort unitid: egen bacompl150 = max(bacompl150x)

gen fraccomplba150 = bacompl150/bacohort

keep if grtype==8

save "grad_2009.dta", replace


clear
use "degenrollempstaff_inst_8018.dta"

keep if year==2009
merge 1:1 unitid using "grad_2009.dta"
rename _merge mergegrad
drop if mergegrad==2


preserve
keep if four_yr==1
collapse fraccomplba150 [aw=bacohort], by(cty_fips)

merge 1:1 cty_fips using "justnormasylum.dta"
rename _merge mergenorm
keep if mergenorm==3

tostring cty_fips, gen(cty_fipstr)
gen statefip = substr(cty_fipstr, 1,1) if length(cty_fipstr)==4
replace statefip = substr(cty_fipstr, 1, 2) if length(cty_fipstr)==5
destring statefip, replace

local vars  fraccomplba150
foreach x of local vars{
reghdfe `x' hasnormalschool, absorb(statefip) cluster(statefip)
outreg2 using instchars.xls, excel append dec(3)

#delimit ;
tabout hasnormalschool if hasnormalorasylum==1 & e(sample)==1 using sumstats_instchars.xls,
append c(mean `x' sd `x') npos(row) f(2)  layout(row) sum show(none); 
#delimit cr
} 
